<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- 填写充值信息页面 -->
<section class="main-content chooseAccount view">
	<div class="recharge-header">
		<div class="title">填写信息</div>
	</div>
	<div class="mid-content">
		<p class="p-title">存到以下账户后，请填写存款信息</p>
		<div class="bank-info">
			<p class="bank-name"><img src="http://wcweb-1254050727.file.myqcloud.com/backend.rechargecenter.cc/upload/pay_manage/20180118/6e8a0a5874a7ab4df7c405e5602788ce.png"><span></span></p>
			<p class="kahao"></p>
			<p class="kaihuming"></p>
			<p class="zhihang"></p>
			<p class="allow-money">￥10.00 - 1000000.00元</p>
		</div>
	</div>
	<div class="bottom-content">
		<div autocomplete="off" class="writeInfoForm ivu-form ivu-form-label-right">
			
			<div class="ivu-form-item"><label class="ivu-form-item-label" style="width: 100px;">存款人姓名</label>
				<div class="ivu-form-item-content cunkName" style="margin-left: 100px;"><input placeholder="存款人姓名">
				</div>
			</div>
			<div class="ivu-form-item"><label class="ivu-form-item-label" style="width: 100px;">存款人账号</label>
				<div class="ivu-form-item-content cunkNumber" style="margin-left: 100px;"><input class="accountNumber" placeholder="存款人账号">
				</div>
			</div>
			<div class="ivu-form-item"><label class="ivu-form-item-label" style="width: 100px;">存款金额</label>
				<div class="ivu-form-item-content" style="margin-left: 100px;"><input type="number" placeholder="请输入金额" class="amount">
				</div>
			</div> 
			<button type="button" class="button writeInfoButton ivu-btn"><!----> <!----> <span>确认存款</span></button>
		 </div> 
	</div>
</section>
<script type="text/javascript">
var state = true;
$.ajax({
	url: "/users/acountBank.do",
	type: "post",
	data: {},
	success: function(data) {
		var newData = data.data;
		if(newData.length <= 0) {
			bindLayerLittle("提示：", "银行卡转账通道已经关闭")
			window.location.href = "/pc/personal.do#chooseGroup"
			return false;
		} else {
			var chooseMoney = localStorage.getItem("chooseMoney")
			Bankmessage = localStorage.getItem("Bankmessage")
			Bankmessage = Bankmessage.split(",")
			$(".chooseAccount .bank-name").find("span").text(Bankmessage[0])
			$(".chooseAccount .kahao").text("卡号:" + Bankmessage[3])
			$(".chooseAccount .kaihuming").text("开户名:" + Bankmessage[1])
			$(".chooseAccount .zhihang").text("支行:" + Bankmessage[2])
			$(".chooseAccount .ivu-form-item-content .amount").val(chooseMoney)
			$(".chooseAccount .writeInfoButton").on("click", function() {
				if($(".ivu-form-item-content input").val() == "") {
					bindLayerLittle("提示：", "存款人不能为空")
					return false;
				}
				var bankmoney = $(".ivu-form-item-content .amount").val();
				console.log(bankmoney,'bankmoney的值')
				if(bankmoney == "") {
					bindLayerLittle("提示：", "存款金额不能为空")
					return false;
				}
				if(bankmoney <= 0) {
					bindLayerLittle("提示：", "无效的金额")
					return false;
				}
				var accountNumber = $(".ivu-form-item-content .accountNumber").val()
				if(accountNumber == "") {
					bindLayerLittle("提示：", "存款人账号不能为空哦")
					return false;
				}
				if(!checkIsNumber(accountNumber) || accountNumber.length<15 || accountNumber.length>20 ){
					bindLayerLittle("提示：", "存款账号格式有误")
					return false;
				}
				$("#code").val("")
				$.ajax({
					type: "post",
					url: "/users/userMoney.do",
					success: function(data) {
						if(data.message == 0) {
							$.ajax({
								url: "/users/shoudongcz.do",
								type: "post",
								data: {
									"zhifupt": Bankmessage[0],
									"fukuanje": $(".chooseAccount .amount").val(),
									"ckname": $(".chooseAccount .cunkName input").val(),
									"zhifuzh": $(".chooseAccount .cunkNumber input").val(),
									"skname": Bankmessage[1], //
									"skbankzh": Bankmessage[3],
									"hydengji": "网银转账",
								},
								success: function(data) {
									var newData = data.data
									bindLayerLittle("提示：", "转账成功，等待客服确认")
									$("#czrecord").addClass("ivu-menu-item-selected")
									window.location.href = "/pc/personal.do#czrecord"
								}
							})
						} else {
							$(".code").attr("src", "/u/code.do?" + Math.random());
							$("#div-i-noticeGenDan2").modal("show");
							$("#code").val("")
							$(".tips").text("")
						}
					}
				})
			})
			
			
				$("#div-i-noticeGenDan2").on("click","#confirm1",function() {
					if(state) {
						state = false; 
						$.ajax({
							url: "/users/shoudongcz.do",
							type: "post",
							data: {
								"zhifupt": Bankmessage[0],
								"fukuanje": $(".chooseAccount .amount").val(),
								"ckname": $(".chooseAccount .cunkName input").val(),
								"zhifuzh": $(".chooseAccount .cunkNumber input").val(),
								"skname": Bankmessage[1], //
								"skbankzh": Bankmessage[3],
								"hydengji": "网银转账",
								"code": $("#code").val(),
							},
							success: function(data) {
								var yanzhengma = $("#code").val()
								if(yanzhengma.length > 4) {
									$(".tips").text("")
								}
								if(data.data == "验证码输入不正确! ") {
									$(".tips").text("验证码不正确，请重新输入")
									state = true;
								} else {
									$(".tips").text("")
									$("#code").val("")
									$("#div-i-noticeGenDan2").modal("hide");
									var newData = data.data
									bindLayerLittle("提示：", "转账成功，等待客服确认")
									$("#czrecord").addClass("ivu-menu-item-selected")
									window.location.href = "/pc/personal.do#czrecord"
								}
							}
						})
					} 
				})
		}
	}
})	


</script>
